#version 120 

uniform sampler2D positions;
uniform sampler2D velocities;
uniform sampler2D forceTexture;
uniform int dataW;
uniform int dataH;

vec2 lookup (vec2 coords) {
	return vec2  ((float(coords.x)+0.5)/dataW, (float(coords.y)+0.5)/dataH);
}


void main(){
	
	vec3 position    = texture2D (positions, gl_TexCoord[0].xy).xyz;
	vec3 newVelocity = texture2D (velocities, gl_TexCoord[0].xy).xyz;
	vec3 force       = texture2D (forceTexture, lookup(position.xy)).xyz;
	
	newVelocity += force*0;
	gl_FragData[1] = vec4(newVelocity,1);
}